/* 请求函数配置 */
import DEVICEUPKEEP from 'service/apis/deviceUpkeep'
import Request from 'service/request'

// 获取查询参数
export async function getQueryParameter(params) {
  return Request({
    url: DEVICEUPKEEP.QUERY_PARAMETER + '?ver=' + (new Date()).getTime(),
    data: params,
    isForm: 0
  })
}
// 获取设备保养列表
export async function getUpkeepList(params) {
  return Request({
    url: DEVICEUPKEEP.GET_UPKEEP_LIST + '?ver=' + (new Date()).getTime(),
    data: params,
    isForm: 0,
    method: 'POST'
  })
}
// 操作保养
export async function operUpkeep({id,method}) {
  return Request({
    url: DEVICEUPKEEP.OPER_UPKEEP + '/' + id,
    isForm: 0,
    method
  })
}
// 保养详情页面
export async function getUpkeepDetail({id}) {
  return Request({
    url: DEVICEUPKEEP.OPER_UPKEEP + '/' + id + '?ver=' + (new Date()).getTime(),
    isForm: 0,
  })
}
// 获取保养计划任务列表
export async function getUpkeepPlanList({ id, current, size}) {
  return Request({
    url: `${DEVICEUPKEEP.UPKEEP_PLAN_LIST}/${id}?current=${current}&size=${size}`,
    isForm: 0,
    method: 'GET'
  })
}
// 启用保养计划的操作
export async function stopOpenUpkeep({ id, status }) {
  return Request({
    url: `${DEVICEUPKEEP.STOP_OPEN_UPKEEP}/${id}?status=${status}`,
    isForm: 0,
    method: 'GET'
  })
}
// 请求保养项目任务列表
export async function getTaskList(params) {
  return Request({
    url: DEVICEUPKEEP.GET_TASK_LIST,
    isForm: 0,
    method: 'POST',
    data: params
  })
}

// 添加保养计划
export async function addUpkeep(params) {
  const data =  Request({
    url: DEVICEUPKEEP.OPER_UPKEEP,
    isForm: 0,
    method: 'POST',
    data: params
  })
  return data
}

// 编辑保养计划
export async function editUpkeep({data,id}) {
  return Request({
    url: DEVICEUPKEEP.OPER_UPKEEP + '/' + id,
    isForm: 0,
    method: 'PUT',
    data
  })
}

// 操作任务的方法  确认完成 不合格
export async function operTask({id, status}) {
  return Request({
    url: `${DEVICEUPKEEP.OPER_TASK}/${id}?status=${status}`,
    isForm: 0,
    method: 'GET'
  })
}
